import wsd.sys.jdbcManager

public execute(o) {
    return new mc(o)
}

class mc {

    def mypara
    def datalist = []
    def itemlist = []

    public mc(f) {
        this.mypara = f;

        index()
    }

    def index() {
        def zt = javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getSessionMap().containsKey("zt");
        if (zt) {
            select()
            javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("zt")
        }
        println(zt)
    }
    def lbselectrow = null

    def select() {
        def conn = null
        try {
            datalist = [];
            itemlist = [];
            conn = groovy.sql.Sql.newInstance(mypara.hqcon(2))
            def chaxun = "select id ,invoice_number,report_time,reporter,department,contract_number,client_name,money_all,invoice_type,auditor,audit_time from feiyongdan where 1 = 1"

            conn.eachRow(chaxun) {
                def t = ["id": it.id, "invoice_number": it.invoice_number, "report_time": it.report_time, "reporter": it.reporter, "department": it.department,
                         "contract_number": it.contract_number, "client_name": it.client_name, "money_all": it.money_all, "invoice_type": it.invoice_type, "auditor": it.auditor, "audit_time": it.audit_time]
                datalist.add(t)
            }

            def chaxun2 = "SELECT  feiyongdan_id, yongtu FROM feiyongdanList;"

            conn.eachRow(chaxun2) {
                def t = ["feiyongdan_id": it.feiyongdan_id, "yongtu": it.yongtu]
                itemlist.add(t)
                println(t)
            }

            mypara.msg("查询成功")
            println(11111)
            conn.commit()
        } catch (Exception e) {
            e.printStackTrace();
            println(e)
        } finally {
            if (conn != null) {
                conn.close()
            }
        }
    }

    def update() {
        javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("invoice_number", datalist["invoice_number"]);
        jdbcManager.navikzbd("/ext/FeiYongDan.xhtml", "费用单", "fyd-demo");
        //javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("zt")
    }

    def delete() {
        javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("zt", "zt");
        jdbcManager.navikzbd("/ext/FeiYongDan.xhtml", "费用单", "fyd-demo");
        //javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("zt")
    }



}